<%@ page contentType="text/html;charset=utf-8"%>
<html lang="zh">
<head>
<title>聊天---用户</title>
<script src="js/jquery-3.1.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/chat.css" />
<script>
	$(document).ready(function() {
		//发送消息
		$("#send").click(function(){
			var content=$("#textarea").val();
			$.ajax({
				type:"post",
				url:"addChat.action",
				data:{content:content},
				success:function(msg){
				}
			});
			$(".chat01_content").append("<div>我:"+content+"</div>");
			$("#textarea").val("");
		});
		var id=-1;
		setInterval(function(){
			$.ajax({
				type:"post",
				url:"getChat.action",
				data:{userFrom:"s10001"},
				success:function(msg){
					if(msg!="fail"){
						var newId=msg.split("_")[0];
						if(id!=newId){
							$(".chat01_content").append("<div>"+msg.split("_")[1]+"客服:"+msg.split("_")[4]+"           "+msg.split("_")[3]+"</div>");
							id=newId;
						}
					}
					
				}
			});
		},3000);
		
		
		//结束回话
		$(".close_btn").click(function(){
			alert("1");
			$.ajax({
				type:"post",
				url:"addChat.action",
				data:{content:"[endchat]"},
				success:function(msg){
				}
			});
		});
		
		
	});
	
	

	
	
	
</script>
<style type="text/css">

</style>

<body class="keBody">
<div class="kePublic">
    <div class="content">
        <div class="chatBox">
            <div class="chatLeft">
                <div class="chat01">
                    <div class="chat01_title">
                        <ul class="talkTo">
                            <li><a href="javascript:;">客服</a></li></ul>
                        <a class="close_btn" href="#"></a>
                    </div>
                    <div class="chat01_content">
                    </div>
                </div>
                <div class="chat02">
                    <div class="chat02_title">
                       
                        <div class="wl_faces_box">
                            <div class="wlf_icon">
                            </div>
                        </div>
                    </div>
                    <div class="chat02_content">
                        <textarea id="textarea"></textarea>
                    </div>
                    <div class="chat02_bar">
                        <ul>
                           
                            <li  id="send" style="right: 5px; top: 5px;"><a href="javascript:;">
                                <img src="img/send_btn.jpg"></a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div style="clear: both;">
            </div>
        </div>
    </div>
</div>
</body>
</html>